package com.moco.launcher.fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

import com.moco.launcher.R;
import com.moco.launcher.listener.FragmentListener;

public class ADRFragment extends BaseFragment {
	private static final String TAG = "ADRFragment";
	
	private ImageView mImgViewExit = null;
	private ImageView mImgViewPlayNext = null;
	private ImageView mImgViewPlayPrev = null;
	private ImageButton mBtnPause;
	private SeekBar mProgress;
	private FragmentListener mListener = null;

	public void registerCallback(FragmentListener l) {
		mListener = l;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.adr_layout, container, false);
		mImgViewExit = (ImageView)rootView.findViewById(R.id.playcontrol_exit);
		mImgViewExit.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Log.d(TAG, "onClick..........");
				if (mListener != null)
					mListener.finishActivity();
			}
		});

		mImgViewPlayPrev = (ImageView)rootView.findViewById(R.id.prev);
		mImgViewPlayPrev.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
			}
		});

		mImgViewPlayNext = (ImageView)rootView.findViewById(R.id.next);
		mImgViewPlayNext.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
			}
		});

		mBtnPause = (ImageButton) rootView.findViewById(R.id.mediacontroller_play_pause);
		if (mBtnPause != null) {
			mBtnPause.requestFocus();
			mBtnPause.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					// TODO: 
				}
			});

			mProgress = (SeekBar) rootView.findViewById(R.id.mediacontroller_seekbar);
			if (mProgress != null) {
				if (mProgress instanceof SeekBar) {
					SeekBar seeker = (SeekBar)mProgress;
					seeker.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

						@Override
						public void onProgressChanged(SeekBar seekBar,
								int progress, boolean fromUser) {
							// TODO:

						}

						@Override
						public void onStartTrackingTouch(SeekBar seekBar) {
							// TODO:

						}

						@Override
						public void onStopTrackingTouch(SeekBar seekBar) {
							// TODO:

						}
					});
				}
				mProgress.setMax(1000);
			}
		}

		return rootView;
	}

}
